﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace SMS.dao
{
    //Luân
    class UserDao
    {
        private static readonly UserDao INSTANCE = new UserDao();

        public static UserDao Instance
        {
            get
            {
                return INSTANCE;
            }
        }

        private UserDao() { }

        public DataTable findUser(string userName, string password)
        {
            String sql = "select USR_NAME, USR_PASS from USR " +
                         "where usr_name = @userName and usr_pass = @passWord and " +
                                "cast(USR_NAME as VARBINARY(150)) = cast(@userName as VARBINARY(150))";
            DataFetcher.Instance.setCommand(sql, 1);
            DataFetcher.Instance.addParameter(new SqlParameter("@userName", userName));
            DataFetcher.Instance.addParameter(new SqlParameter("@passWord", SMS.util.Encoder.Instance.getSHA1HashData(password)));
            return DataFetcher.Instance.fetch();
        }

        
    }
}
